<template>
  <div class="share" v-if="item">
    <!-- 标题被点击,跳转到分享详情页面并携带当前文章的id -->
    <div
      @click="$router.push('/shareDetail/' + item.id)"
      class="title"
      v-html="item.title"
    ></div>
    <p>{{ item.content }}</p>
    <div class="bottom">
      <div class="user" v-if="item.author.avatar">
        <img :src="baseURL + item.author.avatar" alt="" />
        <span>{{ item.author.nickname }}</span>
      </div>
      <div class="other">
        <span class="time">{{ item.created_at | getTime }}</span>
        <span class="comment">
          <i class="iconfont iconicon_pinglunliang"></i>
          {{ item.article_comments }}
        </span>
        <span class="star">
          <i class="iconfont iconbtn_dianzan_small_nor"></i>
          {{ item.star }}
        </span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ['item'],
  data () {
    return {
      baseURL: process.env.VUE_APP_BASEURL
    }
  }
}
</script>
<style lang="less" scoped>
.share {
  padding: 0 15px;
  background-color: #fff;
  padding-bottom: 25px;
  .title {
    font-size: 16px;
    font-weight: 550;
    color: #181a39;
    line-height: 1.25em;
    padding: 12px 0;
  }
  p {
    font-size: 14px;
    color: #545671;
    line-height: 1.35em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .bottom {
    display: flex;
    font-size: 12px;
    align-items: center;
    margin-top: 10px;
    .user {
      display: flex;
      align-items: center;
      flex: 1;
      img {
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: block;
        margin-right: 10px;
      }
    }
    .other {
      color: #b4b4bd;
      .comment {
        margin-left: 16px;
      }
      .star {
        margin-left: 16px;
      }
      .iconfont {
        margin-right: 4px;
        vertical-align: middle;
      }
    }
  }
}
</style>
